import React from 'react';
import {
    Text,
    View,
} from 'react-native';

export default class ChatScreen extends React.Component {

    static navigationOptions = ({ navigation }) => ({
        title: `欢迎你， ${navigation.state.params.user}！`,
        // header: null,
    });

    componentDidMount(){
        this._init();
    }

    render() {
        return (
            <View>
                <Text>这是第2页</Text>
            </View>
        );
    };

    _init():void{
        const {navigate, goBack, state} = this.props.navigation;
        // 在第二个页面,在goBack之前,将上个页面的方法取到,并回传参数,这样回传的参数会重走render方法
        state.params.callback('恭喜你成功获得了回传参数!');
        goBack();
    }
}
